package com.ctshk.rpc.tour.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.tour.dto.cache.ScheduleCustomFeeAdjustAndTouristDTO;
import com.ctshk.rpc.tour.entity.SeriesTripScheduleCustomFeeAdjust;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 团期自定义模板-调整项目 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-02-01
 */
public interface SeriesTripScheduleCustomFeeAdjustMapper extends BaseMapper<SeriesTripScheduleCustomFeeAdjust> {

    /**
     * 查询团期调整费用项列表
     *
     * @param scheduleIds
     * @param tripIds
     * @return
     */
    @Select({"<script>",
            "SELECT cfa.schedule_id,cfa.cost_id,cfa.trip_id,cfa.main_data_id,",
            "project_name,stt.main_data_id AS tourist_type_id,",
            "adjust_type,exchange_rate,price,date_subsection_id",
            "FROM `t_series_trip_schedule_custom_fee_adjust` cfa ,",
            "t_series_trip_schedule_custom_adjust_tourist cat ,",
            "t_series_trip_schedule_tourist_type stt ",
            "WHERE cfa.id = cat.adjust_id",
            "and cfa.cost_id = cat.cost_id",
            "and stt.id = cat.trip_tourist_type_id",
            "and cfa.schedule_id = cfa.schedule_id",
            "and (cfa.is_deleted = 0 or cfa.is_deleted is null)",
            "and cfa.main_data_id = #{feeAdjustId}",
            "and price > 0",
            "and cfa.trip_id IN ",
            "<foreach collection='tripIds' item='trip_id' open='(' separator=',' close=')'>",
            "#{trip_id}",
            "</foreach>",
            "and cfa.schedule_id IN ",
            "<foreach collection='scheduleIds' item='schedule_id' open='(' separator=',' close=')'>",
            "#{schedule_id}",
            "</foreach>",
            "</script>"})
    List<ScheduleCustomFeeAdjustAndTouristDTO> selectCustomFeeAdjustList(List<Long> scheduleIds, Set<Long> tripIds, Long feeAdjustId);
}
